home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 65.zip
/
BS1 part 65
/
Math Visin v2.1 disk 1.adf
/
Arexx.WB
/
Animation
/
MakeAnimation
< prev
next >
Wrap
Text File
|
1992-02-12
|
8KB
|
293 lines
/* MakeAnimation compress each frame before storing to disk 23-Apr-90 dh
The program creates animation files directly, by using the program
RecordAnim in the support directory. Currently, only Delta short compression
is used.
This program is designed for doing short, generic animations, to be
played with the user's animation player.
You have the option of varying the coordinates, the parameter 'p', or
both during the animation.
RecordAnim displays an ARexx port named RECORDANIM, and supports the
following commands.
OpenAnim Screen Filename
- opens the file, and allocates buffers
Screen is exressed in hexadecimal, ie. 27F8C0
Filename tells what file to create/overwrite
AddFrame
- adds the contents of the screen to the animation
CloseAnim
- closes the anim file, deallocates buffers
Quit
- terminates RecordAnim program, does CloseAnim if necessary
============================================================================ */
ADDRESS "MathVision"
OPTIONS RESULTS
OPTIONS FAILAT 20
NUMERIC DIGITS 14
SIGNAL ON ERROR
ERR_NO_FILE = 10
ERR_NO_MEMORY = 11
Xmin0 = 0; XMax0 = 1
Ymin0 = 0; YMax0 = 1
Xmin1 = 0; XMax1 = 1
Ymin1 = 0; YMax1 = 1
VaryCoords = 1
VaryParameter = 0
ParameterStart = 0
ParameterEnd = 1
Frames = 10
FileName = "RAM:Animation"
ClrScr = D2C(12)
StopSign "F"
/* make sure RecordAnim is running */
if (Show("PORTS","RECORDANIM")==0) THEN
DO
Say "Running RecordAnim"
ADDRESS COMMAND "Run MathVision:Support/RecordAnim"
END
DO WHILE command ~= "X"
command = MENU()
SELECT
WHEN command ='V' THEN
DO
VaryCoords = GetBoo("Vary Coordinates", VaryCoords)
VaryParameter = GetBoo("Vary Parameter", VaryParameter)
END
WHEN command ='P' THEN
DO
ParameterStart = GetAns("Starting Parameter", ParameterStart )
ParameterEnd = GetAns("Ending Parameter", ParameterEnd )
END
WHEN command ='C' THEN
DO
if (GetBoo("Change Starting Coordinates", 0)~=0) THEN
DO
if (GetBoo("Get Coordinates from MathVision",0)~=0) THEN
DO
Get XMin; Xmin0 = RESULT
Get XMax; XMax0 = RESULT
Get YMin; Ymin0 = RESULT
Get YMax; YMax0 = RESULT
END
ELSE
DO
XMin0 = GetAns("XMin",XMin0)
XMax0 = GetAns("XMax",XMax0)
YMin0 = GetAns("YMin",YMin0)
YMax0 = GetAns("YMax",YMax0)
END
END
if (GetBoo("Change Ending Coordinates", 0)~=0) THEN
DO
if (GetBoo("Get Coordinates from MathVision",0)~=0) THEN
DO
Get XMin; Xmin1 = RESULT
Get XMax; XMax1 = RESULT
Get YMin; Ymin1 = RESULT
Get YMax; YMax1 = RESULT
END
ELSE
DO
XMin1 = GetAns("XMin",XMin1)
XMax1 = GetAns("XMax",XMax1)
YMin1 = GetAns("YMin",YMin1)
YMax1 = GetAns("YMax",YMax1)
END
END
END
WHEN command = 'F' THEN Frames = GetAns("Frames", Frames )
WHEN command = 'A' THEN CALL Animate
WHEN command = 'D' THEN Filename = GetAns("Filename", FileName )
OTHERWISE;
END /*select*/
END
ADDRESS RECORDANIM "Quit"
EXIT
/*================================== MENU ================================= */
MENU:
SAY ClrScr "---------------- Animate Menu -----------------"
SAY
SAY "V - Vary: Coordinates=("Boo2Text(VaryCoords)")"
SAY " Parameter =("Boo2Text(VaryParameter)")"
if (VaryCoords~=0)
THEN
DO
SAY "C - Coords Start: Xmin " XMin0 " Xmax " XMax0
SAY " Ymin " YMin0 " Ymax " YMax0
SAY " End: Xmin " XMin1 " Xmax " XMax1
SAY " Ymin " YMin1 " Ymax " YMax1
END
if (VaryParameter~=0)
THEN SAY "P - Parameter: ("ParameterStart") to ("ParameterEnd") variable 'p'"
SAY "F - Frames ("Frames")"
SAY "D - Filename ("FileName")"
SAY "A - Animate"
SAY "X - Exit"
OPTIONS PROMPT "--------------> "
PULL Command
RETURN command
/*================================== ZOOM ================================= */
Animate:
Get PlotScreen; Screen = RESULT
ADDRESS RECORDANIM OpenAnim Screen Filename
if (rc==ERR_NO_FILE) THEN
DO
SayError("Not Enough Memory For Animation")
return(0)
END
if (rc==ERR_NO_FILE) THEN
DO
SayError("Could Not Open The File '"filename"'.")
return(0)
END
IF (VaryCoords~=0) THEN
DO
XCenter0 = (XMin0+XMax0)/2
YCenter0 = (YMin0+YMax0)/2
XWidth0 = (XMax0-XMin0)
YWidth0 = (YMax0-YMin0)
XCenter1 = (XMin1+XMax1)/2
YCenter1 = (YMin1+YMax1)/2
XWidth1 = (XMax1-XMin1)
YWidth1 = (YMax1-YMin1)
xfactor = xwidth1/xwidth0
yfactor = ywidth1/ywidth0
END
IF (VaryParameter~=0) THEN
DO
ParameterWidth = ParameterEnd - ParameterStart
END
PlotScreenToFront
DO PictureNumber = 0 TO Frames-1 /* for each picture...*/
SAY "Plotting Frame: "PictureNumber
mult = (PictureNumber) / (Frames-1) /* 0..1 */
IF (VaryParameter~=0) THEN
DO
P mult*ParameterWidth+ParameterStart
END
IF (VaryCoords~=0) THEN
DO
if (PictureNumber == 0) THEN /* avoid ARexx bug with -0 */
DO
XMin Xcenter0-XWidth0/2
XMax Xcenter0+XWidth0/2
YMin Ycenter0-YWidth0/2
YMax Ycenter0+YWidth0/2
END
ELSE
DO
xmag = power(xfactor,mult)
ymag = power(yfactor,mult)
xwidth = xwidth0*xmag
ywidth = ywidth0*ymag
xcenter = xcenter0+((xcenter1-xcenter0)*(xmag-1) / (xfactor-1) )
ycenter = ycenter0+((ycenter1-ycenter0)*(ymag-1) / (yfactor-1) )
Xmin xcenter-xwidth/2 /* plug in the new values */
Xmax xcenter+xwidth/2
Ymin ycenter-ywidth/2
Ymax ycenter+ywidth/2
END
END
Plot /* do the appropriate plot */
ADDRESS RECORDANIM AddFrame /* save it in anim file */
Get StopSign
IF Result = "T" THEN BREAK
END /* do */
StopSign "F"
ADDRESS RECORDANIM CloseAnim
return(0)
RETURN
/* --------------------------------- GetAns -------------------------------- */
/* result = GetAns( prompt, default) */
/* prompt for input, displaying default. Accept one item. If only <return> */
/* was pressed, return the default answer */
GetAns: PROCEDURE
parse arg prompter, default
Options Prompt Prompter "(" Default "): "
pull response
if (response = "") THEN response = default;
return(response)
/*------------------------------- GetBoo ----------------------------------- */
/* result = GetBoo( prompt, default) */
/* prompt for boolean input, where 0 means false an <>0 means true */
/* parse the user input appropriately */
GetBoo: PROCEDURE
parse arg prompter, default
ans = GetAns( prompter, Boo2Text(default) )
if (ans==Boo2Text(default))
THEN return(default); /* pressed return! */
ans = left(ans,1,)
ret = 1
if(Index("0nN",ans)~=0)
THEN ret = 0;
return(ret)
/*----------------------------- Boo2Text ----------------------------------- */
/* result = Boo2Text( bnumber ) */
Boo2text:
parse arg bnumber
if (bnumber==0)
THEN return("No")
ELSE return("Yes")
/*------------------------------- SayError --------------------------------- */
/* display error message and wait for action */
SayError: PROCEDURE
parse arg prompter
say prompter
Options Prompt "Press <RETURN> to continue: "
pull response
return( 0 )
POWER: /* number to power */
arg base, pow
Get Eval base"^"pow /* kick Mathvision to evaluate this */
return(result)
ERROR: /* Error Diagnostic for return codes */
Get Diagnosis RC
SAY RESULT" on line "SIGL
DO i = 1 to 5000
END
EXIT